package simple.engine.world;

import simple.engine.objects.Vector2f;
import simple.engine.objects.Vector3f;

public class SimpleCamera {
	
	private Vector2f mPositionLimitX = new Vector2f(Float.MIN_VALUE, Float.MAX_VALUE);
	private Vector2f mPositionLimitY = new Vector2f(Float.MIN_VALUE, Float.MAX_VALUE);
	private Vector3f mCameraPosition = new Vector3f();
	
	// Getters and setters
	
	public float getX()
	{
		return mCameraPosition.getX();
	}
	
	public float getY()
	{
		return mCameraPosition.getY();
	}
	
	public float getZ()
	{
		return mCameraPosition.getZ();
	}
	
	public void setX(float value)
	{
		mCameraPosition.setX(value);
	}
	
	public void setY(float value)
	{
		mCameraPosition.setY(value);
	}
	
	public void setZ(float value)
	{
		mCameraPosition.setZ(value);
	}
	
	// Constructor
	
	public SimpleCamera(float x, float y, float z)
	{
		mCameraPosition.setValue(x, y, z);
	}
	
	// Methods
	
	public void setPosition(float x, float y, float z)
	{
		mCameraPosition.setValue(x, y, z);
	}
	
	public void setPositionLimit(float x1, float x2, float y1, float y2)
	{
		mPositionLimitX.setX(x1);
		mPositionLimitX.setY(x2);
		
		mPositionLimitY.setX(y1);
		mPositionLimitY.setY(y2);
	}
	
	public void moveCamera(float x, float y, float z)
	{
		float posX = mCameraPosition.getX() + x;
		float posY = mCameraPosition.getY() + y;
		
		if(mPositionLimitX.getX() <= posX && posX <= mPositionLimitX.getY()) mCameraPosition.setX(posX);
		if(mPositionLimitY.getX() <= posY && posY <= mPositionLimitY.getY()) mCameraPosition.setY(posY);
		
		mCameraPosition.setZ(mCameraPosition.getZ() + z);
	}
	
	// Overrides
	
	@Override
	public String toString() {
		return mCameraPosition.toString();
	}
	
}
